﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TA.DotNetUtils;
using TA.JSON;

namespace TA.Turbo.Controls
{
	/// <summary>
	/// Collection of <see cref="RepeaterGrouping"/>s which describe a <see cref="Repeater"/>'s groupings.
	/// </summary>
	public class RepeaterGroupingCollection : VList<RepeaterGrouping>, IJsonCompatible
	{
		#region PUBLIC
		#region INIT
		#endregion
		#endregion
		#region INTERNAL
		#region VARS
		#endregion
		#region METHODS
		#region JSON
		/// <summary>
		/// IsDirty.
		/// </summary>
		public bool IsDirty
		{
			get { return this.Count > 0; }
		}
		/// <summary>
		/// Serialize.
		/// </summary>
		/// <param name="jw"></param>
		public void Serialize(JsonWriter jw)
		{
			this.SerializeArray(jw);
		}
		/// <summary>
		/// SerializeContents.
		/// </summary>
		/// <param name="jw"></param>
		public void SerializeContents(JsonWriter jw)
		{
			foreach (RepeaterGrouping g in this)
				g.Serialize(jw);
		}
		/// <summary>
		/// Deserialize.
		/// </summary>
		/// <param name="jr"></param>
		public void Deserialize(JsonReader jr)
		{
			this.DeserializeArray(jr);
		}
		/// <summary>
		/// DeserializeContent.
		/// </summary>
		/// <param name="jr"></param>
		/// <param name="propShortName"></param>
		public void DeserializeContent(JsonReader jr, string propShortName)
		{
			RepeaterGrouping g = new RepeaterGrouping();
			g.Deserialize(jr);
			this.Add(g);
		}
		#endregion
		#endregion
		#endregion
	}
}
